<?php
class Helper_Comment_Tree  extends C_Helper
{
	public function getTree($comment_ES, $level = 0)
	{
		$level += 1;
		if(!empty($comment_ES))
		foreach($comment_ES as $comment_E)
		{
			 //	if($comment_E->userid != $userid && $comment_E->sign == 0) continue; 
				$g = "";
				if($comment_E->fid == 0)
				{
					$str = $this->fstyleTree($level, $comment_E, $str);
				}
				else 
				{	
					if($comment_E->end == 0)
					{
						$str .= '<ul class="children">';
						$str = $this->fstyleTree($level, $comment_E, $str);
					}
					else 
					{
						$str = $this->styleTree($level, $comment_E, $str);
					}
				}
				if($comment_E->end == 0)
				{
					$str .= $this->getTree(Comments::getRoot($comment_E->forumid, $comment_E->id),$level);
				}
				if($comment_E->fid == 0)
				{
					$str .= '</li>';
				}
				else 
				{	
					if($comment_E->end == 0)
					{
						$str .= '</li>';
						$str .= '</ul>';
						
						
						
					}
				}
				
		}
		return $str;
	}
	
	private function  fstyleTree($level, $comment_E, $str)
	{
		if($level%2 == 1)
		{
			$class = "alt";
		}
		$str .= '<li id="comment-94677" class="comment '.$class.'">';
					$str .= '<div class="comment-body" id="div-comment-94677">';
						$str .= '<div class="comment-author vcard">';
						$str .= '<span class="says">'.$level.'楼</span>';
						$str .= '</div>';
						$str .= '<div class="comment-meta commentmetadata">';
						$str .= '<a href="#">'.$comment_E->getCtime('Y-m-d H:i').'</a>';
						$str .= '</div>';
						$str .= '<p><img alt="" src="'.$comment_E->mapUser->getImage().'" class="avatar avatar-32 photo" height="32" width="32">';
						$str .= '<a href="'.$comment_E->mapUser->getHref().'"><img src="'.$comment_E->mapUser->getIcon().'" >@'.$comment_E->mapUser->getName().'</a>说：'.$comment_E->getContent().'</p>';
						$str .= '<div class="reply">';
						$str .= '<a  href="javascript:reply('.$comment_E->id.')">回复</a>	';
						$str .= '</div>';
					$str .= '</div>';
					
					
					
					
            return $str;
	}
	private function  styleTree($level, $comment_E, $str)
	{
		if($level%2 == 1)
		{
			$class = "alt";
		}
				$str .= '<ul class="children">';
					$str .= '<li id="comment-94677" class="comment '.$class.'">';
						$str .= '<div class="comment-body" id="div-comment-94678">';
							$str .= '<div class="comment-author vcard">';
							$str .= '<span class="says">'.$level.'楼</span>';
							$str .= '</div>';
							$str .= '<div class="comment-meta commentmetadata">';
							$str .= '<a href="#">'.$comment_E->getCtime('Y-m-d H:i').'</a>';
							$str .= '</div>';
							$str .= '<p><img alt="" src="'.$comment_E->mapUser->getImage().'" class="avatar avatar-32 photo" height="32" width="32">';
							$str .= '<a href="'.$comment_E->mapUser->getHref().'"><img src="'.$comment_E->mapUser->getIcon().'" >@'.$comment_E->mapUser->getName().'</a>说：'.$comment_E->getContent().'</p>';
							$str .= '<div class="reply">';
							$str .= '<a  href="javascript:reply('.$comment_E->id.')">回复</a>	';
							$str .= '</div>';
						$str .= '</div>';
					$str .= '</li>';
				$str .= '</ul>';
            return $str;
	}
}
//
//<li id="comment-94677" class="comment even thread-even depth-1 parent">
//		<div class="comment-body" id="div-comment-94677">
//			<div class="comment-author vcard">
//			<span class="says">说：</span>
//			</div>
//	
//			<div class="comment-meta commentmetadata">
//			<a href="#">2010-11-06于16:55</a>
//			</div>
//
//			<p>通宵看过天琴座流星雨，没看着。前几天看英仙座流星雨看到了20多颗，很不错，貌似还看到个火流星，很炫。一边听歌一边等流星最惬意了。</p>
//
//			<div class="reply">
//			<a  href="/archives/45044.html?replytocom=94677#respond" class="comment-reply-link" rel="nofollow">回复</a>		
//			</div>
//		</div>
//		<ul class="children">
//			<li id="comment-94678" class="comment odd alt depth-2">
//				<div class="comment-body" id="div-comment-94678">
//					<div class="comment-author vcard">
//					<span class="says">说：</span>		
//					</div>
//	
//					<div class="comment-meta commentmetadata">
//					<a href="#">2010-11-06于16:56</a>
//					</div>
//	
//					<p>猎户座那天下雨阴天，看不了</p>
//		
//					<div class="reply">
//					<a onclick="#" class="comment-reply-link" rel="nofollow">回复</a>		
//					</div>
//				</div>
//			</li>
//		</ul>
//</li>

//<li id="comment-94677" class="comment even thread-even depth-1 parent">
//	<div class="comment-body" id="div-comment-94677">
//		<div class="comment-author vcard">
//		<span class="says">说：</span>
//		</div>
//		<div class="comment-meta commentmetadata">
//		<a href="#">2010-11-06于16:55</a>
//		</div>
//		<p>你好的啊</p>
//		<div class="reply"><a  href="#">回复</a>	</div>
//	</div>
//<ul class="children">
//<ul class="children">
//<li id="comment-94677" class="comment even thread-even depth-1 parent">
//	<div class="comment-body" id="div-comment-94677">
//		<div class="comment-author vcard">
//		<span class="says">说：</span>
//		</div>
//		<div class="comment-meta commentmetadata">
//		<a href="#">2010-11-06于16:55</a>
//		</div>
//		<p>我好啊</p>
//		<div class="reply"><a  href="#">回复</a>	</div>
//	</div>
//<ul class="children"><ul class="children">
//<li id="comment-94677" class="comment even thread-even depth-1 parent"><div class="comment-body" id="div-comment-94677"><div class="comment-author vcard"><span class="says">说：</span></div><div class="comment-meta commentmetadata"><a href="#">2010-11-06于16:55</a></div><p>他好啊</p><div class="reply"><a  href="#">回复</a>	</div></div></ul></ul></li><li id="comment-94677" class="comment even thread-even depth-1 parent"><div class="comment-body" id="div-comment-94677"><div class="comment-author vcard"><span class="says">说：</span></div><div class="comment-meta commentmetadata"><a href="#">2010-11-06于16:55</a></div><p>呵呵</p><div class="reply"><a  href="#">回复</a>	</div></div></li>

?>